home *** CD-ROM | disk | FTP | other *** search
/ IRIX Installation Tools & Overlays 2002 November / SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso / dist / cluster_admin.idb / var / cluster / ha / diags / volume.pl.z / volume.pl
Perl Script  |  2002-10-15  |  6KB  |  201 lines

  1. #!/usr/sbin/perl
  2. #
  3. #  Copyright (C) 1998-2000, Silicon Graphics, Inc.
  4. #  All Rights Reserved.
  5. #
  6. #  UNPUBLISHED -- Rights reserved under the copyright laws of the United
  7. #  States.  Use of a copyright notice is precautionary only and does not
  8. #  imply publication or disclosure.
  9. #
  10. #  THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF
  11. #  SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR
  12. #  DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN
  13. #  PERMISSION OF SILICON GRAPHICS, INC.
  14. #
  15. #  U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  16. #  Use, duplication or disclosure by the Government is subject to
  17. #  restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph
  18. #  (c)(1)(ii) of the Rights in Technical Data and Computer Software
  19. #  clause at DFARS 252.227-7013 and/or in similar or successor clauses
  20. #  in the FAR, or the DOD or NASA FAR Supplement.  Unpublished-- rights
  21. #  reserved under the copyright laws of the United States.
  22. #  Contractor/manufacturer is Silicon Graphics, Inc.,
  23. #  2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
  24. #
  25.  
  26. # PerformVolumeTest
  27. #
  28. # Get all resources for a particular type
  29. # and run the tests against that resource.
  30.  
  31. require "$LibDiagsPath/constants.pl";
  32. require "$LibDiagsPath/libdiags.pl";
  33. require "$LibDiagsPath/recurse.pl";
  34. use POSIX;
  35.  
  36. sub volume {
  37.   local ($machine_name, $resource) = @_;
  38.   local ($this);
  39.   local (@list);
  40.   local ($retv)=$CD_SUCCESS;
  41.  
  42.   &LogEntry();
  43.   &Verbose("Running resource type %s tests on node %s",
  44.        $VOLUME, $machine_name);
  45.  
  46.   if ($resource eq "ALL") {
  47.     @list=&GetResFromResType($machine_name, $VOLUME);
  48.     if (scalar(@list) < 1) {
  49.       &Failure("No resources found for resource type %s",$VOLUME);
  50.       return $CD_FAILURE;
  51.     }
  52.     foreach $this (@list) {
  53.        $retv=&TestVolume($machine_name,$this);
  54.  
  55.        # If the DESTRUCTIVE flag is set ...
  56.        if ($DESTRUCTIVE) {
  57.        if (&Execvolume($machine_name,$this) == $CD_FAILURE) {
  58.            &Failure("Resource %s of resource resource type %s failed",$this,
  59.             $VOLUME);
  60.            $retv=$CD_FAILURE;
  61.        }
  62.        }
  63.        &ExitStatus($retv);
  64.     }
  65.   }else {
  66.     # We have been given the resource name.
  67.     $retv=&TestVolume($machine_name, $resource);
  68.  
  69.     # If the DESTRUCTIVE flag is set ...
  70.     if ($DESTRUCTIVE) {
  71.     if (&Execvolume($machine_name,$resource) == $CD_FAILURE) {
  72.         &Failure("Resource %s of type %s failed",$resource,
  73.              $VOLUME);
  74.         $retv=$CD_FAILURE;
  75.     }
  76.     }
  77.     &ExitStatus($retv);
  78.   }
  79.   return $retv;
  80. }
  81.  
  82. sub Execvolume {
  83.     local ($node, $resource) = @_;
  84.     local ($retv);
  85.  
  86.     &LogEntry();
  87.  
  88.     &Status("Starting resource %s of resource type %s on node %s",
  89.          $resource,$VOLUME,$node);
  90.  
  91.     # Only execute the destructive tests on this node.
  92.     if (!&OnTheSameNode($node)) {
  93.     &Notice("Can only execute the resource destructive tests on local host");
  94.     &Log("Can only execute the resource destructive tests on local host %s/%s",
  95.           $this_host, $NodeToHost{$node});
  96.     return $CD_SUCCESS;
  97.     }
  98.  
  99.     &Status("Executing the $VOLUME resource scripts, I.e. probe, exclusive, start, monitor and stop");
  100.     &Status("Please be patient ...");
  101.     foreach $script (@HA_LIST) {
  102.     $retv=ExecuteScript($node,$resource,$VOLUME,$script);
  103.     if ($retv == 0) {
  104.         # script failed, exit
  105.         return $CD_FAILURE;
  106.     }
  107.     # Sleep a while
  108.     sleep(3);
  109.     }
  110.     return $CD_SUCCESS;
  111. }
  112.  
  113. # TestVolume
  114. # The resource test has three parts
  115. #   1) Check the resource parameters.
  116. #   2) If the resource has dependencies check them.
  117.  
  118. sub TestVolume {
  119.     local ($machine, $volume) = @_;
  120.     local ($status);
  121.     local ($cmd);
  122.     local ($retv);
  123.     local ($mode,$group,$owner,@parameters);
  124.  
  125.     $retv=$CD_SUCCESS;
  126.  
  127.     &LogEntry();
  128.     &Status("Testing resource %s of resource type %s on node %s",
  129.          $volume,$VOLUME,$machine);
  130.  
  131.     # Check the resource attributes.
  132.     @parameters=&GetResParameters($machine_name,$VOLUME,$volume);
  133.     if (scalar(@parameters) < 1 ) {
  134.       &Failure("No parameters returned for resource %s of resource type %s",
  135.            $resource,$VOLUME);
  136.       return $CD_FAILURE;
  137.     }
  138.     if ($parameters[0] < 0){
  139.       &Failure("No parameters found for resource %s of resource type %s",
  140.            $resource,$VOLUME);
  141.       return $CD_FAILURE;
  142.     }
  143.  
  144.     if (($owner=&pulloff("devname-owner",@parameters)) eq "") {
  145.       &Failure("%s resource %s does not have the %s parameter set",
  146.            $VOLUME,$volume,"devname-owner");
  147.       $retv=$CD_FAILURE;
  148.     }
  149.  
  150.     if (($group=&pulloff("devname-group",@parameters)) eq "") {
  151.       &Failure("%s resource %s does not have the %s parameter set",
  152.            $VOLUME,$volume,"devname-group");
  153.       $retv=$CD_FAILURE;
  154.     }
  155.  
  156.     if (($mode=&pulloff("devname-mode",@parameters)) eq "") {
  157.       &Failure("%s resource %s does not have the %s parameter set",
  158.            $VOLUME,$volume,"devname-mode");
  159.       $retv=$CD_FAILURE;
  160.     }
  161.  
  162.     # Add simple tests, tests taken from FailSafe 1.2.
  163.  
  164.     # Check if xlv_mgr is present. The volumes script uses
  165.     # xlv_mgr. This is installed using a xlv patch. If the
  166.     # particular xlv patch is not installed, HA will fail.
  167.     $cmd="ls -l /sbin/xlv_mgr > /dev/null";
  168.     @output=&rsh($machine,$cmd);
  169.     if ($RSH_ERRNO != 0) {
  170.        &Failure("/sbin/xlv_mgr command not present on node %s",$machine);
  171.        # No point continuing ...
  172.        return $CD_FAILURE;
  173.     }
  174.  
  175.     $cmd="/sbin/xlv_mgr -Rc \"show config\" > /dev/null";
  176.     @output=&rsh($machine,$cmd);
  177.     if ($RSH_ERRNO != 0) {
  178.        &Failure("Some xlv patches have not been installed on the system");
  179.        $retv=$CD_FAILURE;
  180.     }
  181.  
  182.     # Check that the volume exists ...
  183.     $cmd="/sbin/xlv_mgr -c\"show -short $volume\" > /dev/null";
  184.     @output=&rsh($machine,$cmd);
  185.     if ($RSH_ERRNO != 0) {
  186.       &Failure("Resource %s of resource type %s has not been created or does not exist on node %s",
  187.            $volume,$VOLUME,$machine);
  188.       $retv=$CD_FAILURE;
  189.     }
  190.  
  191.     # Check for the plexing licence
  192.     $cmd="/sbin/xlv_mgr -Rc \"show config\" | grep \"Plexing license\" | grep \"not\"";
  193.     @output=&rsh($machine,$cmd);
  194.     if ($RSH_ERRNO == 0) {
  195.       &Warning("Check if XLV license has been installed on node %s",
  196.            $machine);
  197.       $retv=$CD_SUCCESS;
  198.     }
  199.     return ($retv);
  200. }
  201.